package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.MallActivityExchange;
import com.sc.nft.mapper.MallActivityExchangeMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * IP商城活动兑换配置表(sc_mall_activity_exchange)数据DAO
 *
 * @author zxy
 * @since 2023-05-10 16:59:01
 * @description IP商城
 */
@Slf4j
@Repository
public class MallActivityExchangeDao extends ServiceImpl<MallActivityExchangeMapper, MallActivityExchange> {

    public List<MallActivityExchange> getListByActivityIdAndSpecsid(Long mallActivityId, Long specsId,Long groupId) {
        LambdaQueryWrapper<MallActivityExchange> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallActivityExchange::getActivityId, mallActivityId);
        wrapper.eq(MallActivityExchange::getActivitySpecsId, specsId);
        if (groupId != null) {
            wrapper.eq(MallActivityExchange::getGroupId, groupId);
        }
        wrapper.eq(MallActivityExchange::getGroupId, groupId);
        return this.list(wrapper);
    }

    public List<MallActivityExchange> getListByActivityIdAndSpecsidOld(Long mallActivityId, Long specsId) {
        LambdaQueryWrapper<MallActivityExchange> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallActivityExchange::getActivityId, mallActivityId);
        wrapper.eq(MallActivityExchange::getActivitySpecsId, specsId);
        return this.list(wrapper);
    }


    public List<MallActivityExchange> getByActivityId(Long mallActivityId) {
        LambdaQueryWrapper<MallActivityExchange> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallActivityExchange::getActivityId, mallActivityId);
        return this.list(wrapper);
    }
}